{%extends 'base.html'%}
{%block title%}吾有言{%endblock%}
{%block content%}
<div class='container' align=center>
{%if message%}
<div class='alert alert-warming'>{{message}}</div>
{%endif%}
<form name='my form' action='/' method='GET'>
	现在的心情；<br />
	{%for m in moods%}
	<input type='radio' name = 'mood' value = '{{m.status}}'>{{m.status}}
	{%endfor%}
	<br />
	心情留言板：<br />
	<textarea name = 'user_post' rows = 3 cols = 70></textarea><br />
	<label for='user_id'>您的昵称</label>
	<input id = 'user_id' type = 'text' name='user_id'><br />
	<label for = 'user_pass'>张贴密码：</label>
	<input id = 'user_pass' type='password' name='user_pass'><br />
	<input type='submit'value = '张贴'>
	<input type='reset'value = '擦除'>
</form>
<div class='row'>
	<div class='col-md-12'>
		<div class='panel panel-default'>
			<div class='panel-heading' align=center>
			<h3>~~宝宝心里苦，只能在此说~~</h3>
			</div>
		</div>
{%for p in posts%}
	{%cycle "<div class='row'> <div class='col-md-4'>" "<div class='col-md-4'>" "<div class='col-md-4'>" %}
		<div class='panel panel-primary'>
			<div class='panel-heading'>【{{p.nickname}}】觉得{{p.mood}}</div>
			<div class='panel-body'>{{p.message|linebreaks}}</div>
			<div class='panel-footer' align='right'><i><small>{{p.pub_time}}</small></i> <span class='glyphicon glyphicon-trash' onclick = 'go_delete({{p.id}})'></span></div>
			<script>
			function go_delete(id){
				var user_pass=document.getElementById('user_pass').value;
				if(user_pass!=''){
					var usr='/del'+id+'/'+user_pass
					window.location = usr;
				}
			}
			</script>
		</div>
	</div>
	{%cycle '' '' '</div>'%}
{%endfor%}
</div>
{%endblock%}